/**
 * user：tangjunbin 
 * 2012 7 -25
 */
$(function() {
	$("#form").bind(
			"submit",
			function() {
				$(".error").hide();
				var c = true;
				var b = "valid_";
				//验证是否为空
				$("input." + b + "noempty").each(
						function(e, f) {
							if (!this.disabled && !$.trim(this.value)) {
								var g = $(this);
								$("#" + g.attr("error_dom_id")).text(
										g.attr(b + "noempty_error")).show();
								this.focus();
								c = false;
								return false
							}
						});
				if (!c) {
					return false
				}
				//验证邮箱格式
				var a = /^[0-9a-zA-Z\.\_-]+@([0-9a-zA-Z-]+\.)+[a-z]{2,4}$/;
				$("input." + b + "email").each(
						function(e, f) {
							var g = $.trim(this.value);
							if (!this.disabled && g && !a.test(g)) {
								var h = $(this);
								$("#" + h.attr("error_dom_id")).text(
										h.attr(b + "email_error")).show();
								this.focus();
								c = false;
								return false
							}
							if(!this.disabled && g && a.test(g)){
								var h = $(this);
								var th = this;
								$.ajax({
									type:'POST',
									async:false,
									dataType:"json",
									url:check_url,
									data:{"index":"usermail","usermail":g},
									success:function (re){
										if(re.state == 0){
											$("#" + h.attr("error_dom_id")).text(re.usermail).show();
											th.focus();
											c = false;
										}else{
											$("input[name=tjb_mail]").val(re.usermail);
											$("input[name=tjb_box]").val(re.box);
										}
									}
								})
							}
						});
				if (!c) {
					return false
				}
				$("input." + b + "username").each(
						function(e, f) {
							var g = $.trim(this.value);
							var h = $(this);
							var th = this;
							if(!this.disabled && g){
								$.ajax({
									type:'POST',
									async:false,
									dataType:"json",
									url:check_url,
									data:{"index":"usermail","usermail":g},
									success:function (re){
										if(re.state == 0){
											$("#" + h.attr("error_dom_id")).text(re.usermail).show();
											th.focus();
											c = false;
										}else{
											$("input[name=tjb_mail]").val(re.usermail);
											$("input[name=tjb_box]").val(re.box);
										}
									}
								})
							}
						});
				if (!c) {
					return false
				}
				//验证  邮箱是否正确 over
				$("input." + b + "email_over").each(
						function(e, f) {
							var g = $.trim(this.value);
							var h = $(this);
							var th = this;
							if(!this.disabled && g){
								$.ajax({
									type:'POST',
									async:false,
									dataType:"json",
									url:check_url,
									data:{"index":"over_mail","over_mail":g,"tjb_box":tjb_box},
									success:function (re){
										if(re.state == 0){
											$("#" + h.attr("error_dom_id")).text(re.usermail).show();
											th.focus();
											c = false;
										}
									}
								})
							}
						});
				if (!c) {
					return false
				}
				//验证  验证码是否正确
				$("input." + b + "vertify").each(
						function(e, f) {
							var g = $.trim(this.value);
							var h = $(this);
							var th = this;
							if(!this.disabled && g){
								$.ajax({
									type:'POST',
									async:false,
									dataType:"json",
									url:vertify_url,
									data:{"index":"vertify","vertify":g},
									success:function (re){
										if(re.state == 0){
											$("#" + h.attr("error_dom_id")).text(re.msg).show();
											th.focus();
											c = false;
										}
									}
								})
							}
						});
				if (!c) {
					return false
				}
			})
});
var bdPass = bdPass || {};
bdPass.voidFunc = function() {
};
bdPass.timeDown = function(d, a, e, c) {
	e();
	var b = setInterval(function() {
		a(d--);
		if (d == -1) {
			clearInterval(b);
			c()
		}
	}, 1000)
};
bdPass.bindDescribeEvents = function() {
	$("a.describe_button_a").click(function() {
		$(this).parent().next(".describe").toggle();
		return false
	});
	$("div.describe_close").click(function() {
		$(this).parent().hide()
	});
	var a = $(".describe");
	$(document).click(function(b) {
		if ($(b.target).parents(".describe").length) {
			return true
		} else {
			a.hide()
		}
	})
};